﻿' ----------------------------------------------------------------------------------
' Microsoft Developer & Platform Evangelism
' 
' Copyright (c) Microsoft Corporation. All rights reserved.
' 
' THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ----------------------------------------------------------------------------------
' The example companies, organizations, products, domain names,
' e-mail addresses, logos, people, places, and events depicted
' herein are fictitious.  No association with any real company,
' organization, product, domain name, email address, logo, person,
' places, or events is intended or should be inferred.
' ----------------------------------------------------------------------------------

Namespace UserAccountWrappers
    Public Class FormsAuthenticationService
        Implements IFormsAuthentication
        Public ReadOnly Property FormsCookieName() As String Implements IFormsAuthentication.FormsCookieName
            Get
                Return FormsAuthentication.FormsCookieName
            End Get
        End Property

        Public Sub SignIn(ByVal userName As String, ByVal createPersistentCookie As Boolean) Implements IFormsAuthentication.SignIn
            If String.IsNullOrWhiteSpace(userName) Then
                Throw New ArgumentNullException("userName", "User name cannot be null nor empty.")
            End If

            FormsAuthentication.SetAuthCookie(userName, createPersistentCookie)
        End Sub

        Public Sub SignOut() Implements IFormsAuthentication.SignOut
            FormsAuthentication.SignOut()
        End Sub

        Public Function Encrypt(ByVal ticket As FormsAuthenticationTicket) As String Implements IFormsAuthentication.Encrypt
            Return FormsAuthentication.Encrypt(ticket)
        End Function

        Public Function Decrypt(ByVal token As String) As FormsAuthenticationTicket Implements IFormsAuthentication.Decrypt
            Return FormsAuthentication.Decrypt(token)
        End Function
    End Class
End Namespace